<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
<input type="text" id="btn1" value="按钮">
<script>
	window.onload=function () {
	  let obtn = document.getElementById("btn1");
	  obtn.onclick =function () {
		//1.创建对象
	    let xhr = new XMLHttpRequest();
	    //2.连接
	    xhr.open('GET','./data/1.txt',true);//true异步
	    //3.发送
	    xhr.send();
	    //4.接收
	    xhr.onreadystatechange=function () {
	    	if(xhr.readyState===4){
	    		if(
	    			(xhr.status>=200 && xhr.status<300) ||
					xhr.status==304){
	    			//....成功
			      console.log(xhr);
			    }else {
	    			//...失败
			    }
		    }
		};
	  }
	}
</script>
</body>
</html>